package com.yc.springboot.web;

import com.yc.springboot.bean.MyProperties;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Company 源辰信息
 *
 * @author navy
 * @date 2024/8/18
 * Email haijunzhou@hnit.edu.cn
 */
@RestController
@Slf4j // 会自动生成 log 日志实例变量
public class IndexAction {

    @RequestMapping("hello")
    String hello(){
        log.debug("========debug 调试=======");
        log.info("========info 信息=======");
        log.warn("========warn 告警=======");
        log.error("========debug 错误=======");
        return "hello spring boot";
    }

    @Value("${demo.name:李四}")
    String myname;

    @Value("${demo.age}")
    int myage;

    @RequestMapping("myinfo")
    String myinfo(){
        return myname + ":" + myage;
    }

    @Autowired
    MyProperties myProperties;

    @RequestMapping("myProps")
    MyProperties myProperties(){
        return myProperties;
    }

}
